package org.phalanx.gwt.client.shared;

import java.util.ArrayList;
import java.util.Iterator;

public class PresentationListener {
	private ArrayList<WebPresentable> pListenerTable;
	
	public PresentationListener(){
		pListenerTable = new ArrayList<WebPresentable>();
	}
	
	public void addPresentationPanelListener(WebPresentable pClass){
		if (!pListenerTable.contains(pClass)){
			pListenerTable.add(pClass);
		}
	}
	
	public void removePresentationPanelListener(WebPresentable pClass){
		if (pListenerTable.contains(pClass)){
			pListenerTable.remove(pClass);
		}
	}
	
	public void setLoadingEvent(OnLoadEvent e){
		Iterator<WebPresentable> i = pListenerTable.iterator();
		
		while (i.hasNext()){
			WebPresentable wP = i.next();
			
			wP.onContentLoading(e);
		}
	}
	
	public void setLoadedEvent(OnLoadEvent e){
		Iterator<WebPresentable> i = pListenerTable.iterator();

		while (i.hasNext()){
			WebPresentable wP = i.next();
			
			wP.onContentLoaded(e);
		}
	}
}
